[SPARK-57081][TESTS] Fix percent-encoding issue in SparkTestUtils classpath handling#56125
Open
sarutak wants to merge 3 commits into
Open
[SPARK-57081][TESTS] Fix percent-encoding issue in SparkTestUtils classpath handling#56125sarutak wants to merge 3 commits into
sarutak wants to merge 3 commits into
Conversation
Replace URL.getFile() with new File(url.toURI).getPath in SparkTestUtils.scala to correctly handle classpath URLs containing percent-encoded characters (e.g., spaces encoded as %20). URL.getFile() returns percent-encoded strings, so paths containing spaces or special characters are not resolved correctly when passed to File constructors or compiler classpath arguments. Using url.toURI properly decodes the path. Four call sites are fixed: - createCompiledClass - createJarWithJavaSources - createJarWithScalaSources - expandManifestClasspath
HyukjinKwon
approved these changes
May 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
This PR replaces
URL.getFile()withnew File(url.toURI).getPath(ornew File(url.toURI)) inSparkTestUtils.scalato correctly handle classpath URLs containing percent-encoded characters (e.g., spaces encoded as%20).Four call sites are fixed:
createCompiledClasscreateJarWithJavaSourcescreateJarWithScalaSourcesexpandManifestClasspathAdditionally, a new test suite
SparkTestUtilsSuiteis added to cover both this fix and theexpandManifestClasspathlogic introduced in #55564.Why are the changes needed?
URL.getFile()returns a percent-encoded string. When a classpath URL contains spaces or special characters (e.g.,C:\Program Files\...or CI environments with spaces in paths), the encoded string (e.g.,/path%20with%20spaces/lib.jar) is passed directly to the compiler ornew File(...), which fails to resolve the actual file. Usingurl.toURIproperly decodes the path.Without this change, tests which use
SparkTestUtilsfails if the repository is in the path containing white spaces.Does this PR introduce any user-facing change?
No.
How was this patch tested?
Confirmed
ClassLoaderIsolationSuitepassed even if the repository is in a space containing path.Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude (via Kiro CLI, auto model selection)